//
//  ViewController.m
//  makepack_tools
//
//  Created by tangs on 2017/7/15.
//  Copyright © 2017年 tangs. All rights reserved.
//

#import "LogViewController.h"

@implementation LogViewController
@synthesize index;

- (void)viewDidLoad {
    [super viewDidLoad];
    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(onLog:)
                                                 name:@"add_log"
                                               object:nil];
}

- (void)viewDidDisappear {
    [[NSNotificationCenter defaultCenter] removeObserver:self];
}

- (void)setRepresentedObject:(id)representedObject {
    [super setRepresentedObject:representedObject];

    // Update the view, if already loaded.
}

- (void)onLog:(NSNotification *) noti {
    if ([self.index integerValue] == 0) {
        NSString *str = noti.userInfo[@"log"];
        NSAttributedString* attr = [[NSAttributedString alloc] initWithString:str];
        [[self.log textStorage] appendAttributedString:attr];
        [self.log scrollRangeToVisible:NSMakeRange([[self.log string] length], 0)];
    }
}

@end
